package com.mapull.example.section2;

/**
 * StringToLong
 *
 * @author mapull
 * @date 2021-09-07
 * @since 1.0
 **/
public class StringToLong {

    public static void main(String[] args) {
        try {
            int intVal = Integer.parseInt("a123");//java.lang.NumberFormatException
            System.out.println(intVal);
        }catch (NumberFormatException e){
            System.out.println("字符串解析失败 " + e.getMessage());
        }
    }
    public static void main4(String[] args) {
        long v1 = Long.parseUnsignedLong("+100");
        System.out.println(v1);

        long v2 = Long.parseUnsignedLong("-100"); //java.lang.NumberFormatException
    }
    public static void main3(String[] args) {
        Long v1 = new Long("+11");
        System.out.println(v1);
    }
    public static void main2(String[] args) {
        long v1 = Long.parseLong("029");
        System.out.println(v1);

        long v2 = Long.parseLong("+333");
        System.out.println(v2);

        long v3 = Long.parseLong("-020");
        System.out.println(v3);
    }
    public static void main1(String[] args) {
        Long v1 = Long.valueOf("012");
        System.out.println(v1);

        Long v2 = Long.valueOf("+120");
        System.out.println(v2);

        Long v3 = Long.valueOf("-99");
        System.out.println(v3);
    }
}
